﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DEFLib;

namespace DEF
{
	class Program
	{
		static void Main(string[] args)
		{
			FolderDeleterSettings settings = FolderDeleterSettings.LoadFromDisk();
			foreach (string baseDir in settings.BaseDirs)
			{
				IEnumerable<string> dirsToDelete = FolderDeleter.GetDirsToDelete(settings.IgnoreFiles, settings.IgnoreDirs, baseDir);

				Console.WriteLine("Found {0} dirs to delete for base dir {1}.", dirsToDelete.Count(), baseDir);
				foreach (string dir in dirsToDelete)
				{
					Console.WriteLine(dir);
				}

				if (dirsToDelete.Count() > 0)
				{
					Console.WriteLine("Delete {0} listed dirs (Y/N)?", dirsToDelete.Count());
					string reply = Console.ReadLine();
					if (reply.Trim().Equals("y", StringComparison.OrdinalIgnoreCase))
					{
						FolderDeleter.DeleteDirs(dirsToDelete);
					}
				}
				else
				{
					Console.WriteLine("0 dirs found to delete");
				}

				Console.ReadLine();
			}
		}
	}
}
